<?php 
require_once 'class/elFinderConnector.class.php';
require_once 'class/elFinder.class.php';
require_once 'class/elFinderVolumeDriver.class.php';
require_once 'class/elFinderVolumeLocalFileSystem.class.php';
// Required for MySQL storage connector
// include_once 'class/elFinderVolumeMySQL.class.php';
// Required for FTP connector support
// include_once 'class/elFinderVolumeFTP.class.php';

class elfinderPhp
{
	public static function Connector()
	{
		/*$access = create_function('$attr, $path, $data, $volume', "
			return strpos(basename($path), '.') === 0       // if file/folder begins with '.' (dot)
			? !($attr == 'read' || $attr == 'write')    // set read+write to false, other (locked+hidden) set to true
			:  null;   
		");*/
		
		$opts = array(
			// 'debug' => true,
			'roots' => array(
				array(
					'driver'        => 'LocalFileSystem',   // driver for accessing file system (REQUIRED)
					'path'          => FILEMANAGER_DIR,         // path to files (REQUIRED)
					'URL'           => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED)
					'accessControl' => 'access'             // disable and hide dot starting files (OPTIONAL)
				)
			)
		);
		
		// run elFinder
		$connector = new elFinderConnector(new elFinder($opts));
		$connector->run();
	}
	
	protected function access($attr, $path, $data, $volume)
	{
		return strpos(basename($path), '.') === 0       // if file/folder begins with '.' (dot)
		? !($attr == 'read' || $attr == 'write')    // set read+write to false, other (locked+hidden) set to true
		:  null;   
	}
}